package com.bjsxt.mapper;

import com.bjsxt.pojo.Menu;
import com.bjsxt.pojo.TreeA;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MenuMapper {
    //查询指定角色下菜单
    @Select("select * from t_menu where mid in(select mid from t_role_menu where rid in(select rid from t_admin_role where aid=#{param1})) and pid=#{param2}")
    List<Menu> selectMore(Integer aid,Integer pid);
//查询所有菜单
    @Select("select * from t_menu")
    List<Menu> selectAll();

    //异步树查询所有菜单
    @Select("select * from t_menu where pid=#{param1}")
    List<Menu> selectAll2(Integer pid);

    //添加菜单的实现
    @Insert("insert into t_menu(mname,pid,status,url,mdesc) values(#{mname},#{pid},#{status},#{url},#{mdesc})")
    Integer   insert(Menu menu);

    //修改菜单的实现
    @Update("update t_menu set mname=#{mname},pid=#{pid},status=#{status},url=#{url},mdesc=#{mdesc} where  mid=#{mid}")
    Integer update(Menu menu);
    //删除菜单操作
    @Delete("delete from t_menu where mid=#{param1}")
    Integer delete(Integer mid);


    List<TreeA> selectAll3(Integer pid);


}
